package cn.itcast.controller;

import cn.itcast.constant.MessageConstant;
import cn.itcast.entity.Result;
import cn.itcast.mobile.MobileMemberService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Demo class
 *
 * @author gyc
 * @date 2021 /10/17
 */
@RestController
@RequestMapping("/member")
public class MemberController {
    @Reference
    private MobileMemberService memberService;

    /**
     * Login verification result.
     *
     * @param map the map
     * @return the result
     */
    @PostMapping("/login")
    public Result loginVerification(@RequestBody Map map){
        String phone = (String) map.get("phone");
        String code = (String) map.get("validateCode");
        Map retMap = memberService.loginVerification(phone,code);
        return new Result(true, MessageConstant.LOGIN_SUCCESS,retMap);
    }
}
